/**
 * - definicao de objeto {}
 *   
 * - definicao de array []
 * 
 * - definicao de variavel ( var <nomeVariavel> =  )
 * 
 * - definicao de classe function <NomeClasse> () 
 * 
 * 
 */

function Customer() {
	
	this.name = '';
	this.email = '';
	this.phone = '';
	this.contact = new Contact();
	this.address = new Address();
	
	var _all = [];
	
	this.add =  function () {
		_all.push(this);
	};
	
	this.all = function () {
		return _all;
	};
	
}


function Contact () {
	this.twitter = '';
	this.facebook = '';
	this.googleplus = '';

}

function Address () {
	this.address = '';
	this.city = '';
	this.country = '';
	this.state = '';
}

function CustomerController () { 
    	
   this.customer = new Customer();

   var init  = function () {
	   customer = new Customer();
	   console.log('init executado');
	   observer();
   };	
 
   save = function() {
	   buildCustomer();
	   this.customer.add();
	   console.log ('Eh Nois ..... Sarvo ;) ');
   };   
   
   var observer = function () {
	   $('#save').click(save);
   };
   
    
   buildCustomer = function() {
        
	   this.customer.name = $('#customer-name').val();
        this.customer.email = $('#customer-email').val();
        this.customer.phone = $('#customer-phone').val();
        
        this.customer.address.address = $('#address').val();
        this.customer.address.city= $('#city').val();
        this.customer.address.state = $('#state').val();
        this.customer.address.country = $('#country').val();

        this.customer.contact.twitter = $('#contact-twitter').val();
        this.customer.contact.facebook = $('#contact-facebook').val();
        this.customer.contact.gooogleplus = $('#contact-gplus').val();
   };
	    
   init();
}




